<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
    <link rel="stylesheet" type="text/css" href="<c:url value="/css/list.css"/>">
    <script type="text/javascript" src="<c:url value="/js/jquery.js"/>"></script>
    <script type="text/javascript">
      
      function del(no,name){
          if(confirm("确定要删除 "+name+" 类别吗?")){
            location.href="<c:url value="/category?act=del&ctg_no="/>"+no;
          }
      }
      
      function mend(no){
          location.href="<c:url value="/category?act=for_update&ctg_no="/>"+no;
      }
	  
	  //pageno 指定页码数
      function doQuery(pageno)
      {
        if(pageno<1 || pageno>${page.totalPageNum})
        {
           alert("页号超出范围，有效范围：[1-"+${page.totalPageNum}+"]!");
           ${'pageNo'}.select();
           return;
        }
        //location.href="<c:url value="/categoryMgr?act=for_list"/>"+"&page_no="+pageno;
        document.forms[0].page_no.value=pageno;
        document.forms[0].submit();
      }
      function doQuery2(){
           
           var pageNo=document.getElementById("pageNo").value;
           doQuery(pageNo);
           
      }
      
      //控制类别编号输入

       onsubmit=function(){
     //    	alert("ddd");
      	var sss=$(":input[name=ctg_no]").val();
     // 不可行   	var sss=document.getElementsByName("ctg_no").value;
         	if(isNaN(sss)){
	            alert("类别编号只能为数字!");
	            return false;
	        }
	     }
	  
  </script>
  
  <body>
      <div class="title">
          <h3>查看商品类别</h3>
          <div class="wrapper_div">
              <form class="search_form" name="content_form" action="<c:url value="category"/>" method="post">
                  <input type="hidden" name="act" value="list_all" size="10"/>
                  <input type="hidden" name="page_no" value=""/>
                  <span>类别名称:</span>
                  <input type="text" name="ctg_name" value="${param.ctg_name}" size="10"/>
                  &nbsp;
                  <span>类别编号:</span>
                  <input type="text" name="ctg_no" value="${param.ctg_no}" size="10" />
                  <input type="submit"  value="查 询"/>
              </form>
          </div>
      </div>
      <hr/>
      <div class="wrapper_div">
          <table class="listtable">
              <thead>
                  <tr>
                      <td>类别编号</td>
                      <td>类别名称</td>
                      <td>父类别编号</td>
                      <td>连接地址</td>
                      <td>操作</td>
                  </tr>
              </thead>
              <tbody>
                  <c:forEach items="${page.pageContent}" var="category">
                      <tr>
                          <td>${category.categoryNo}</td>
                          <td>${category.categoryName}</td>
                          <td>${category.categoryParentNo}</td>
                          <td>${category.categoryURL}</td>
                          <td>
                              <button onclick="javascript:del('${category.categoryNo}','${category.categoryName}');">删 除</button>
                              <button onclick="javascript:mend('${category.categoryNo}');">修 改</button>
                          </td>
                      </tr>
                  </c:forEach>
              </tbody>
          </table>
      </div>
      <div class="page_infos">
	            共${page.totalRecNum}条, 当前显示${page.startIndex}-${page.endIndex}条, 第${page.pageNo}/${page.totalPageNum}页
	           |
	           <c:if test="${page.pageNo>1}">
	             <span class="linkspan" onclick="doQuery(1)">首页</span>&nbsp;
	           </c:if>
	           <c:if test="${page.prePage}">
	             <span class="linkspan" onclick="doQuery(${page.pageNo-1})">上一页</span>&nbsp;
	           </c:if>
	           <c:if test="${page.nextPage}">
	             <span class="linkspan" onclick="doQuery(${page.pageNo+1})">下一页</span>&nbsp;
	           </c:if>
	           <c:if test="${page.pageNo!=page.totalPageNum}">
	             <span class="linkspan" onclick="doQuery(${page.totalPageNum})">末页</span>&nbsp;
	           </c:if>
	           |
	            到<input type="text" id="pageNo" size=4 style="text-align:right;" onkeypress="onlynumber();"/> 页
	        <button onclick="doQuery2();">跳 转</button>          		          	           	              
	  </div>
      <c:if test="${empty page.pageContent}">
          <div class="no_found" style="color:red">
              无法查找到您所要求的信息.......
          </div>
      </c:if>
  </body>
</html>

